package Client;

import General.CallbackInterface;
import General.EventInterface;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.Vector;

public class EventImplementation implements Serializable, EventInterface {
	private static final long serialVersionUID = 2L;
	

	private Vector<String> fNotifications = new Vector<String>();
	private CallbackInterface fCallback;

	public EventImplementation(CallbackInterface callback) {
		super();		
		fCallback = callback;
	}

	public void addNotification(String notification) {		
		fNotifications.add(notification);

		if (fNotifications.size() == 2) {
			try {
				fCallback.notify(fNotifications.get(0) + ". " + fNotifications.get(1) + ".");
				fNotifications.remove(0);
				fNotifications.remove(0);
			} catch (RemoteException e) {
				e.printStackTrace();
			}
		}
	}
}
